#pragma once

#include <memory>
#include "../include/onvif_interface.h"

namespace El {
namespace Onvif {

// 前向声明
class OnvifServerImpl;

/**
 * @brief ONVIF服务器实现类
 * 
 * 实现IOnvifServer接口，使用Pimpl模式隐藏实现细节
 */
class OnvifServer : public IOnvifServer {
public:
    /**
     * @brief 构造函数
     * @param port HTTP服务端口
     */
    explicit OnvifServer(int port = 8080);
    
    /**
     * @brief 析构函数
     */
    ~OnvifServer() override;

    // 实现IOnvifServer接口
    bool Start() override;
    void Stop() override;
    bool IsRunning() const override;

    void SetDeviceInformation(const DeviceInformation& deviceInfo) override;
    DeviceInformation GetDeviceInformation() const override;

    void SetNetworkConfiguration(const NetworkInterface& networkConfig) override;
    NetworkInterface GetNetworkConfiguration() const override;

    void SetOnvifPort(int port) override;
    int GetOnvifPort() const override;

    void EnableWSDiscovery(bool enable) override;
    bool IsWSDiscoveryEnabled() const override;

    void SetSecurityMode(SecurityMode mode) override;
    SecurityMode GetSecurityMode() const override;

    bool AddUser(const User& user) override;
    bool RemoveUser(const std::string& username) override;
    std::vector<User> GetUsers() const override;

    bool AddMediaProfile(const MediaProfile& profile) override;
    bool RemoveMediaProfile(const std::string& token) override;
    std::vector<MediaProfile> GetMediaProfiles() const override;

    ServiceCapabilities GetServiceCapabilities() const override;

private:
    // Pimpl pattern - 隐藏实现细节
    std::unique_ptr<OnvifServerImpl> pImpl_;
};

/**
 * @brief ONVIF服务器工厂实现类
 */
class OnvifServerFactory : public IOnvifServerFactory {
public:
    std::unique_ptr<IOnvifServer> CreateServer(int port = 8080) override;
};

} // namespace Onvif
} // namespace El